package com.bookseek.xreader.views.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.bookseek.xreader.R;
import com.bookseek.xreader.views.fragments.GujiFragment;
import com.bookseek.xreader.views.fragments.GushuFragment;
import com.bookseek.xreader.views.fragments.MyFragment;
import com.bookseek.xreader.views.fragments.PoemFragment;
import com.bookseek.xreader.views.fragments.WenFragment;

public class ViewPagerAdapter extends FragmentStateAdapter {
    // 定义标签数量
    private static final int TAB_COUNT = 4;

    private int[] tabIcons = {
//            R.drawable.ic_round_article_24,
//            R.drawable.ic_round_library_books_24,
//            R.drawable.ic_round_photo_library_24,
//            R.drawable.ic_round_settings_24,

            R.drawable.tab_ic_poem,
            R.drawable.tab_ic_book,
            R.drawable.tab_icon_guji_32,
            R.drawable.tab_ic_wode,
    };
    private String[] tabTitles = {
            "诗词","典籍","古籍","我的"
    };


    public String getTabTitle(int position){
        return tabTitles[position];
    }

    public int getTabIcon(int position){
        return tabIcons[position];
    }


    public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }



    @NonNull
    @Override
    public Fragment createFragment(int position) {
        // 根据位置返回对应的Fragment
        switch (position) {
            case 0:
                return new PoemFragment();
            case 1:
                return new WenFragment();
            case 2:
                return new GushuFragment();
            default:
                return new MyFragment();
        }
    }

    @Override
    public int getItemCount() {
        return tabIcons.length;
    }
}
